home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / ncsat.cpt / Telnet2.5 final / tek / tekmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-23  |  1.3 KB  |  87 lines

  1. #define DEVNULL 0
  2. #define EGA 1
  3. #define POSTSCRIPT 2
  4. #define HERCULES 3
  5. #define NO9 4
  6. #define CGA 5
  7. #define HP 6
  8. #define EP 7
  9. #define ELO 8
  10.  
  11. #define BUFSIZE 6000
  12.  
  13. #include <stdio.h>
  14. #include <dos.h>
  15.  
  16. char testbuf[BUFSIZE]; /* text input buffer */
  17. FILE *plot;
  18.  
  19. writeln(c)
  20. char *c;
  21. {
  22.     fprintf(plot,"%s",c);
  23. }
  24.  
  25. charout(c)
  26. char c;
  27. { fputc(c,plot); }
  28.  
  29. main(argc,argv)
  30. int argc;
  31. char *argv[];
  32. {
  33.     int w1;
  34.  
  35.     VGinit();
  36.     plot=fopen("tekout.x","wb");
  37. /*    RGPoutfunc(writeln);
  38.     RGHPoutfunc(writeln);
  39.     RGEPoutfunc(charout);*/
  40.  
  41.     if (argc < 3) w1=VGnewwin(HERCULES,0);
  42.     else w1=VGnewwin((argv[2][0] - 48),0); /* 2nd param is device number */
  43.  
  44.     VGuncover(w1);
  45.     VGpage(w1);
  46.     if (argc==1) showfile(w1,"file1.tek");
  47.     else showfile(w1,argv[1]); /* 1st param is filepath */
  48.  
  49. /*
  50.     VGpage(w1);
  51.     drawall(w1);
  52.     VGpage(w1);
  53.     VGredraw(w1,w1);
  54. */
  55.  
  56.     VGtmode(w1);
  57.     VGclose(w1);
  58.  
  59. } /* end main() */
  60.  
  61.  
  62. static drawall(vw)
  63. /* redraw the whole thing incrementally */
  64. {
  65.     int i;
  66.     while (!(i=VGpred(vw,vw)));
  67. }
  68.  
  69.  
  70. static showfile(vw,fname)
  71. int vw;
  72. char *fname;
  73. /*
  74.     Read the file named by fname and display it in the window.
  75. */
  76. {
  77.     int datalen,i;
  78.     FILE *fp = fopen(fname,"ra");
  79.     if (fp != NULL) {
  80.         while ((datalen = fread(testbuf,1,BUFSIZE,fp)) > 0) {
  81.             for (i=0; i<datalen ; i++)
  82.                 VGwrite(vw,&testbuf[i], 1);
  83.         }
  84.         fclose(fp);
  85.     }
  86. }
  87.